<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">	

<ui:composition>

	<p:commandButton onclick="adminLayout.show('north')" value="show"></p:commandButton>
	<p:commandButton onclick="adminLayout.hide('north')" value="hide"></p:commandButton>
	<h:form id="roleForm">  
    <p:growl id="roleMessages" showDetail="true"/>  
  
    <p:dataTable var="role" value="#{businessRoleManagementBoundary.model}" id="roleTable" rows="10" editable="true" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink}
{LastPageLink} {RowsPerPageDropdown}" paginatorPosition="bottom" rowsPerPageTemplate="10,20,50">  
        <f:facet name="header">  
            Role-Settings  
        </f:facet>  
  
        <p:ajax event="rowEdit" listener="#{businessRoleManagementBoundary.updateRole}" update="@this"/>  
        <p:ajax event="rowEditCancel" listener="#{businessRoleManagementBoundary.updateRole}" />  
  
  		<p:column style="width:5%">
  			<p:commandLink value="x" actionListener="#{businessRoleManagementBoundary.deleteRole(role)}" update=":#{p:component('roleTable')}"/>
  		</p:column>
  
        <p:column headerText="Title" style="width:20%">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{role.title}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{role.title}" style="width:100%" label="Title"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>  
  
        <p:column headerText="Description" style="width:55%">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{role.description}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{role.description}" style="width:100%" label="Description"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>  
  
        <p:column headerText="Level" style="width:5%">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{role.level}" />  
                </f:facet>  
                <f:facet name="input">  
                    <h:selectOneMenu value="#{role.level}" converter="javax.faces.Integer">  
                        <f:selectItems value="#{businessRoleManagementBoundary.levels}" var="level" itemLabel="#{level}"  
                            itemValue="#{level}" />  
                    </h:selectOneMenu>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>  
  
        <p:column headerText="GoalOwnerPermission" style="width:10%">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{role.goalOwnerPermission}" />  
                </f:facet>  
                <f:facet name="input">  
                    <h:selectOneMenu value="#{role.goalOwnerPermission}">  
                    	<f:selectItem itemLabel="true" itemValue="true"/>
                    	<f:selectItem itemLabel="false" itemValue="false"/>
                    </h:selectOneMenu>  
                </f:facet>  
            </p:cellEditor>  
        </p:column>  
  
        <p:column style="width:5%">  
            <p:rowEditor />  
        </p:column>  
  
    </p:dataTable>  
</h:form>  

<p:dialog id="insertRoleDialog" header="Insert New Role" widgetVar="insertRoleDlg" position="center" width="500" height="180" resizable="false">  
	<h:form>  
        <p:panelGrid columns="2" cellpadding="5" style="width:100%;">  
         
	            <p:outputLabel for="titleInputText" value="Title:" />  
	            <p:inputText value="#{businessRoleManagementBoundary.title}"   
	                    id="titleInputText" required="true" label="title"/> 
	           	  
	           	<p:outputLabel for="descriptionInputText" value="Description: " />  
	            <p:inputText value="#{businessRoleManagementBoundary.description}"   
	                    id="descriptionInputText" required="false" label="description"/>               
           
	            <p:outputLabel value="Level: *" />        		
      			<h:selectOneMenu value="#{businessRoleManagementBoundary.level}" converter="javax.faces.Integer" required="true">
      				<f:selectItem  itemLabel="Select Organizational Level" itemValue="-1"/>
      				<f:selectItems value="#{businessRoleManagementBoundary.levels}" var="level" itemLabel="#{level}" itemValue="#{level}"/>
      			</h:selectOneMenu>
      	
      			<p:outputLabel value="Owner Permission: " />
      			<h:selectOneMenu value="#{businessRoleManagementBoundary.goalOwnerPermission}" converter="javax.faces.Boolean">
      				<f:selectItem itemLabel="true" 	itemValue="true"  />
      				<f:selectItem itemLabel="false" itemValue="false" />
      			</h:selectOneMenu>
      
            <f:facet name="footer">  
                <p:commandButton icon="ui-icon-plus" id="insertRoleButton" value="Insert" actionListener="#{businessRoleManagementBoundary.createRole}"  
                update=":#{p:component('roleTable')},:#{p:component('roleMessages')}"/>  
            </f:facet>  
        </p:panelGrid>  	
	</h:form>  
</p:dialog> 

</ui:composition>
</html>